package com.heima.zuoye.day07.timu3;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo1 {
    public static void main(String[] args) {
        HashMap map = new HashMap<Integer, String>();
        map.put(1, "张三");
        map.put(2, "李四");
        map.put(3, "王五");
        //大小
        System.out.println(map.size());
        //键找值遍历
        Set<Integer> set = map.keySet();
        for (Integer i : set) {
            String s = (String) map.get(i);
            System.out.println(i + ":" + s);
        }
        System.out.println("===========================");
        //键值对遍历
        Set<Map.Entry<Integer, String>> set1 = map.entrySet();
        for (Map.Entry<Integer, String> entry : set1) {
            Integer key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + ":" + value);
        }
        System.out.println(map.get(1));
        System.out.println(map.get(10));
        System.out.println(map.containsKey(10));
        System.out.println(map.remove(1));
        System.out.println(map);
    }
}
